<?php
use shenka\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
//xin Url;
use yii\helpers\Url;
$controller = '神卡系列产品数据查询';
$action = '数据查询';
?>
	

<!-- /section:settings.box -->
<div class="page-header">
	<h1>
		<?php echo $controller;?>
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			<?php echo $action;?>
		</small>
	</h1>
</div><!-- /.page-header -->
<div class="col-xs-12">
	
<div class="content">
	<div class="box" style="margin:13px;" >
		<form  method="post" enctype="multipart/form-data">
			<div class="float-l width40">
				<div>
					<label>产品类型：</label>
					<select name='edition' id="edition" class="input-select">
						<option value="0">选择产品</option>
						<option value="1">星球大冒险</option>
						<option value="2">星球大冒险-主题乐园</option>
						<option value="3">星球大冒险-韩国版</option>
						<option value="4">巨龙重生</option>
						<option value="5">神卡王国-1代</option>
						<option value="6">美术棒</option>
					</select>
				</div>
				<div class="help-block"></div>
				<div>
					<label>查询方式：</label>
					<select name='type' id="type" class="input-select">
						<option value="0">选择查询方式</option>
					</select>
				</div>
				<div class="help-block"></div>
				<div>
					<label>查询信息：</label>
					<input type="text" name='data' id="data" class="input-text" placeholder="请输入查询信息"/>
				</div>
			</div>
			<input type="hidden" name="_csrf" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>"/>
			<a style="margin:20px 0;" type="submit" name="submit" id="j-Submit" class="btn btn-success btn-next" href="javascript:void(0);">查询</a>
		</form>
	</div>
	<div class="col-xs-12">
		<table id="simple-table" class="table table-striped table-bordered table-hover">
			<thead>
				<tr id="j-Head"></tr>
			</thead>

			<tbody>
				<tr id="j-List"></tr>
			</tbody>
		</table>
	</div>
</div>

<div id="reg" style="width:1000px;height:500px;margin:50px auto;"></div>

</div>

<script type="text/javascript" src="./ace/js/jquery.js"></script>
<script type="text/javascript">
	$(function(){
		//条件选择ajax处理，这里将处理二级联动
		$('#edition').on("change",function(){//change事件是select选择触发事件
			var type=$('#edition').val();
			$.ajax({
				type:'post',
				data:{_csrf:'<?= Yii::$app->request->csrfToken ?>',t:type},
				url:'<?= Url::to(['edition/type']);?>',
				success:function(response){
					var data=JSON.parse(response);
					$('#type').html('')
					for(var k in data){
						$('#type').append('<option value='+k+'>'+data[k]+'</option>');
					}
//                    console.log(data);
				}
			});
		})
		//点击查询ajax处理，这里将处理查询到的数据
		$('#j-Submit').on("click",function(){
			$.ajax({
				type:'post',
				data:{_csrf:'<?= Yii::$app->request->csrfToken ?>',
					type:$('#type').val(),
					data:$('#data').val(),
					edition:$('#edition').val()
				},
				url:'<?= Url::to(['edition/submit']);?>',
				success:function(response){
					var data=JSON.parse(response);
					$('#j-Head').html('')
					$('#j-List').html('')
					for(var k in data){
						$('#j-Head').append('<td>'+k+'</td>');
						$('#j-List').append('<td>'+data[k]+'</td>');
					}
					console.log(data);
				}
			});
		})
	});
</script>